'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller, middleware } = app;
  const jwt = middleware.jwtErr(app.config.jwt.secret);
  // 用户相关
  router.post('/api/user/register', controller.user.register);
  router.post('/api/user/login', controller.user.login);
  router.get('/api/user/user', jwt, controller.user.getUserInfo);
  router.post('/api/user/edituser', jwt, controller.user.editUserInfo);
  // 图片相关
  router.post('/api/upload', controller.upload.upload);
  // 账单相关
  router.post('/api/bill/add', jwt, controller.bill.add);
  router.get('/api/bill/list', jwt, controller.bill.list);
  router.get('/api/bill/detail', jwt, controller.bill.detail);
  router.post('/api/bill/update', jwt, controller.bill.update);
  router.post('/api/bill/delete', jwt, controller.bill.delete);
  router.get('/api/bill/data', jwt, controller.bill.data);
  // 消费类型
  router.get('/api/type/list', jwt, controller.type.list);

  router.get('/api/user/test', jwt, controller.user.test);
  // home
  router.get('/', controller.home.index);
  router.post('/add', controller.home.add);
  router.get('/carousel', controller.home.carousel);
  router.post('/add_carousel', controller.home.addCarousel);
  router.put('/edit_carousel', controller.home.editCarousel);
  router.post('/delete_carousel', controller.home.deleteCarousel);
  // 新建任务相关
  router.get('/api/task/getTaskList', controller.task.getTaskList);
  router.post('/api/task/addTask', controller.task.add);
  router.get('/api/task/deleteTask', controller.task.delete);
  router.post('/api/task/completeTask', controller.task.update);
  router.get('/api/task/editTask', controller.task.edit);
  // 商城注册
  router.post('/api/auth/signup', controller.auth.register);
};
